package com.peace.hospital.mapper.drugstorage;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.peace.hospital.entity.drugstorage.Frmloss;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;


/**
 * <p>
 * 药品报损 Mapper 接口
 * </p>
 *
 * @author xie
 * @since 2019-11-12
 */
@Mapper
public interface FrmlossMapper extends BaseMapper<Frmloss> {

//    插入报损单信息
    @Insert("insert into drugstorage.frmloss(staid,frmdate,frmcheckdate,frmdbsource)\n"+
            "values (#{staid},#{frmdate},#{frmcheckdate},#{frmdbsource})")
    public int addFromloss(Frmloss frmloss);
//    查询最新一条报损单信息
    @Select("select frmid from drugstorage.frmloss order by frmid desc limit 1")
    public Frmloss findFrmloss();
// 查询报损单信息

    @Select("<script> select staid,frmid,frmdate,frmcheckdate\n"+
        "from drugstorage.frmloss\n"+
            "<where>"+
            "<if test='frmid != null'>and frmid = #{frmid}</if> "+
            "<if test='frmdate != null'>and frmdate = #{frmdate}</if> "+
            "</where>"+
        "</script>")
    @Results({
            @Result(column="staid",property="staffinfo",one=@One(select="com.peace.hospital.mapper.publicn.StaffinfoMapper.findById",fetchType= FetchType.LAZY)),
    })
    public List<Frmloss> findFrmByFrmid(Frmloss frmloss);
}
